import 'package:duqing/models/recommend_interface.dart';
import 'package:duqing/models/user_model.dart';
import 'package:flutter/cupertino.dart';

class ArticleList {
  final List<ArticleItem> list;

  ArticleList(this.list);

  factory ArticleList.fromJson(List<dynamic> list) {
    return ArticleList(
      list.map((item) => ArticleItem.fromJson(item)).toList(),
    );
  }
}

class ArticleItem implements RecommendInterface {
  final int id;
  final List<dynamic> coverUrlList;
  final String title;
  final Map<String, dynamic> publishAppUserEntity;
  final int commentCount;
  final int thumbUpCount;
  final int readCount;
  final UserItem user;

  ArticleItem(
      {@required this.id,
      @required this.coverUrlList,
      @required this.user,
      @required this.title,
      @required this.publishAppUserEntity,
      @required this.commentCount,
      @required this.thumbUpCount,
      @required this.readCount});

  factory ArticleItem.fromJson(dynamic item) {
    return ArticleItem(
      id: item['id'],
      coverUrlList: item['coverUrlList'],
      user: UserItem.fromJson(item['user']),
      title: item['title'],
      publishAppUserEntity: item['publishAppUserEntity'],
      commentCount: item['commentCount'],
      thumbUpCount: item['thumbUpCount'],
      readCount: item['readCount'],
    );
  }
}

class ArticleInfo {
  final int id;
  final List<dynamic> coverUrlList;
  final String title;
  final Map<String, dynamic> publishAppUserEntity;
  final int commentCount;
  final int thumbUpCount;
  final int readCount;

  ArticleInfo({
    @required this.id,
    @required this.coverUrlList,
    @required this.title,
    @required this.publishAppUserEntity,
    @required this.commentCount,
    @required this.thumbUpCount,
    @required this.readCount,
  });

  factory ArticleInfo.fromJson(dynamic item) {
    return ArticleInfo(
        id: item['id'],
        coverUrlList: item['coverUrlList'],
        title: item['title'],
        publishAppUserEntity: item['publishAppUserEntity'],
        commentCount: item['commentCount'],
        thumbUpCount: item['thumbUpCount'],
        readCount: item['readCount']);
  }
}
